<template>
	<view class="my-center-index">
		<view class="current-user-card" v-if="currentUserCard.names">
			<image src="https://zhyl.setupgx.cn/attachment/app/index/head-portrait.png"></image>
			<p class="card-name">
				{{currentUserCard.names}}({{currentUserCard.numcard}})
			</p>
			<view class="right-btns">
				<u-button type="success" size="small" icon="reload" text="切换" @click="goToPage('/pages/tabbar/myCenter/userCardList')"></u-button>
				<!-- <u-button type="success" size="small" icon="reload" text="测试" @click="test()"></u-button> -->
				<!-- <u-button style="margin-top: 5px;" type="success" size="mini" text="展码" @click="showJianKangKaSC()"></u-button> -->
				<!-- <u-button style="margin-top: 5px;" type="success" size="mini" @click="login()" text="电子健康卡"></u-button> -->
			</view>
		</view>
		<view class="user-info" v-else>
			<block>
				<!-- <view class="uni-h3 uni-center uni-common-mt">未登录</view> -->
				<view class="uni-hello-text uni-center">
					未找到您的档案，请先【<text class="link" @click="goToPage('/pagesB/healthCard/users')">在线建档</text>】
				</view>
			</block>
		</view>
		<u-modal :show="showJianKangKaModal" :title="'确认'">
			<view class="title">微信授权</view>
			<view class="info">获取你的公开信息（昵称，头像，地区，及性别）</view>
			<!-- 具体参数请对照插件文档按具体业务需求添加 -->
			<health-card-login :wechatcode="true">

				<view class="btn-agree"></view>
			</health-card-login>
		</u-modal>

		<view class="content">
			<uni-section title="常用服务" type="line">
				<uni-grid :column="4" :highlight="true" :showBorder="false" @change="gridChange">
					<uni-grid-item :index="0">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="notification" :size="30" color="#777" />
							<text class="text">我的挂号</text>
						</view>
					</uni-grid-item>
					<!-- <uni-grid-item :index="1">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="phone" :size="30" color="#777" />
							<text class="text">医院热线</text>
						</view>
					</uni-grid-item> -->
					<!-- <uni-grid-item :index="2">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="heart-filled" :size="30" color="#777" />
							<text class="text">我的体检</text>
						</view>
					</uni-grid-item> -->
					<!-- <uni-grid-item :index="3">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="location" :size="30" color="#777" />
							<text class="text">收货地址</text>
						</view>
					</uni-grid-item> -->
					<!-- <uni-grid-item :index="4">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="gift-filled" :size="30" color="#777" />
							<text class="text">药品订单</text>
						</view>
					</uni-grid-item> -->
					<!-- <uni-grid-item :index="5" v-if="showTiJianVerification">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="auth" :size="30" color="#777" />
							<text class="text">体检核验</text>
						</view>
					</uni-grid-item> -->
					<uni-grid-item :index="6">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="chatbubble-filled" :size="30" color="#777" />
							<text class="text">我的咨询</text>
						</view>
					</uni-grid-item>
					<uni-grid-item :index="7">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="wallet-filled" :size="30" color="#777" />
							<text class="text">电子健康卡</text>
						</view>
					</uni-grid-item>
					<uni-grid-item :index="8">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="closeempty" :size="30" color="#777" />
							<text class="text">缴费异常</text>
						</view>
					</uni-grid-item>
					<!-- <uni-grid-item :index="1">
						<view class="grid-item-box" style="background-color: #fff;">
							<i class="iconfont icon-car" style="font-size: 30px; color: #777;"></i>
							<text class="text">车辆管理</text>
						</view>
					</uni-grid-item>
					<uni-grid-item :index="2">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="list" :size="30" color="#777" />
							<text class="text">缴费记录</text>
						</view>
					</uni-grid-item>
					<uni-grid-item :index="3">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="list" :size="30" color="#777" />
							<text class="text">医保卡</text>
						</view>
					</uni-grid-item>
					<uni-grid-item :index="4">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="list" :size="30" color="#777" />
							<text class="text">我的发票</text>
						</view>
					</uni-grid-item>
					<uni-grid-item :index="5">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="list" :size="30" color="#777" />
							<text class="text">添加就诊人</text>
						</view>
					</uni-grid-item>
					<uni-grid-item :index="6">
						<view class="grid-item-box" style="background-color: #fff;">
							<uni-icons type="list" :size="30" color="#777" />
							<text class="text">就诊人</text>
						</view>
					</uni-grid-item> -->
				</uni-grid>
			</uni-section>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations,
		mapActions
	} from 'vuex'

	export default {
		computed: {
			...mapState(['hasLogin'])
		},
		data() {
			return {
				currentUserCard: {
					names: ''
				},
				showTiJianVerification: false,
				showJianKangKaModal: false
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.currentUserCard = uni.getStorageSync('current_user_card')
			this.api_getnurse()
		},
		methods: {
			test() {
				let openid = uni.getStorageSync('openid')
				this.$app._post_form2("entry/wxapp/apipayment.paysucctest", {
					"openid": openid,
					"id": '',
					"pay_order_no": ''
				}, (res) => {
					console.log(res)
					if (res.id != '0') {
						this.showTiJianVerification = true
					}
				})
			},
			showJianKangKaSC() {
				uni.navigateTo({
					url: 'plugin://healthCardPlugins/healthcode?hospitalId=37868&healthCardId=444D68D74B8BC55222A7C3251DC72F056981D47233EB79865100B26085CFF279'
				})
			},
			goToPage(url) {
				uni.navigateTo({
					url: url
				})
			},
			gridChange(e) {
				console.log(e)
				if (e.detail.index == 0) {
					uni.navigateTo({
						url: "/pagesB/tabbar/myCenter/myAppointment"
					})
				}
				if (e.detail.index == 1) {
					uni.showToast({
						title: '功能开发中...',
						icon: 'none'
					})
				}
				if (e.detail.index == 2) {
					uni.navigateTo({
						url: "/pages/healthExamination/myHealthExamination"
					})
				}
				if (e.detail.index == 3) {
					uni.navigateTo({
						url: "/pages/pharmacy/addressList"
					})
				}
				if (e.detail.index == 4) {
					uni.navigateTo({
						url: "/pages/pharmacy/drugOrder"
					})
				}
				if (e.detail.index == 5) {
					uni.navigateTo({
						url: "/pages/healthExamination/doctorVerification"
					})
				}
				if (e.detail.index == 6) {
					uni.navigateTo({
						url: "/pages/onlineInquiry/myInquiry"
					})
				}
				if (e.detail.index == 7) {
					uni.navigateTo({
						url: "/pagesB/healthCard/myHealthCards"
					})
				}
				if (e.detail.index == 8) {
					uni.navigateTo({
						url: "/pages/tabbar/myCenter/payErrors"
					})
				}
			},
			api_getnurse() {
				let openid = uni.getStorageSync('openid')
				this.$app._post_form("entry/wxapp/apicheckup.getnurse", {
					openid: openid
				}, (res) => {
					console.log(res)
					if (res.id != '0') {
						this.showTiJianVerification = true
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.my-center-index {
		padding: 15px;
		background-color: #EFEFF4;
	}

	.current-user-card {
		height: 100px;
		background-color: #fff;
		box-shadow: 0 0 10px #666;
		border-radius: 15px;
		line-height: 100px;
		display: flex;
		align-items: center;
		padding: 0px 15px 0px 15px;

		image {
			width: 50px;
			height: 50px;
			display: flex;
			background-color: #fff;
			border-radius: 50px;
		}

		.card-name {
			display: flex;
			flex: 1;
			margin-left: 10px;
		}
		
		.right-btns {
			display: flex;
			justify-content: flex-end;
			flex-direction: column;
		}

		// .qrcode-btn {
		// 	display: flex;
		// 	justify-content: flex-end;
		// }
	}

	.user-info {
		width: 100%;
		text-align: center;
		background-color: #fff;
		border-radius: 8px;
		padding: 25px 0 25px 0;
	}

	.link {
		color: #41C177;
	}

	.content {
		padding: 10px;
		box-sizing: border-box;
		border-radius: 8px;
		background-color: #ffffff;
		margin-top: 10px;

		.grid-item-box {
			flex: 1;
			// position: relative;
			/* #ifndef APP-NVUE */
			display: flex;
			/* #endif */
			flex-direction: column;
			align-items: center;
			justify-content: center;
			padding: 15px 0;

		}

	}
</style>